class Dog{
    public String name;
    public int age;
    private String color;

    public void eat(){

        System.out.println(name + "吃饭");
    }
    public static void bark(){
        //被static修饰的方法，成为静态方法，静态方法无法直接使用非静态变量，需要在内部
        Dog dog = new Dog();
        System.out.println(dog.age + "岁" + dog.color + dog.name + "汪汪叫");
    }

    public String getColor() {
        //因为color是private修饰的变量，相当于类的私有变量，想要调用，只能通过内部函数调用，下方set同理。
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
    public void showColor(){
        System.out.println(color);
    }
}
public class test{

    public static void main(String[] args) {
        Dog dog1 = new Dog();
        dog1.age = 3;
        dog1.name = "馒头狗";
        dog1.setColor("棕色");
        dog1.eat();
        Dog.bark();
        //dog1.main();
    }

}
